<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php echo $this->Html->charset(); ?>
	<title><?php echo 'SISVENLA' ?></title>
	<?php
            echo $this->Html->meta('icon');
            echo $this->Html->css(array(
                                    'sisvenla', 
                                    //'rojo/jquery-ui.min',
                                    'personalizado/jquery-ui-1.10.4.custom.min',
                                    'jquery.dataTables.min',
                                ));
            echo $this->Html->script(array(
                                        'jquery/jquery', 
                                        //'jquery/jquery-ui.min', 
                                        'jquery/jquery-ui-1.10.4.custom.min', 
                                        'jquery/jquery.validate', 
                                        'jquery/additional-methods', 
                                        'jquery/jquery.maskedinput.min', 
                                        'jquery/jquery.dataTables.min', 
                                        'funciones', 
                                        'boxOver', 
                                    ));

            echo $this->fetch('meta');
            echo $this->fetch('css');
            echo $this->fetch('script');
            
            $perfilId = $this->Util->id_decode($this->Session->read('perfil_id'));
	?>
        <script type="text/javascript">
            $(function(){
                //PREVIENE CLICK DERECHO
                /*$(this).bind("contextmenu", function(e) {
                    e.preventDefault();
                });*/
                
                //GUARDAR LOS PERMISOS DEL USUARIO EN UN OBJETO JS
                /*permiso = '<?php //echo json_encode($this->Session->read('permiso_usuario')); ?>';
                permiso = $.parseJSON(permiso);*/
                
                var divs_transparentDiv = $('div#div_loader');
                divs_transparentDiv.css('display', 'none');
                var divs_transparentDivImg = $('div#div_loader_img');

                //DIMENSIONES DE LA VENTANA
                $.fn.__getBrowserSize = function() {
                    var bodyWidth = $(window).width(),
                        bodyHeight = $(window).height();

                    return [bodyWidth, bodyHeight];
                };

                //POSICIONA LA VENTANA DE CARGA EN EL CENTRO DE LA PANTALLA
                $.fn.__repositionTransparentDiv = function() {
                    divs_transparentDiv.css('top', '0px');
                    divs_transparentDiv.css('left', Math.max($(document.body).scrollLeft(), $(window).scrollLeft()) + 'px');
                    var brSize = $.fn.__getBrowserSize(),
                        bodyWidth = brSize[0],
                        bodyHeight = brSize[1],
                        padtop = (bodyHeight / 2);
                    divs_transparentDiv.css('paddingTop', padtop + 'px');
                    divs_transparentDiv.css('height', '2000px');
                };

                //MUESTRA LA VENTANA DE CARGA
                $.fn.show_div_loader = function() {
                    divs_transparentDiv.css('display', 'block');
                    divs_transparentDivImg.css('display', 'block');
                    var st = Math.max($(document.body).scrollTop(), $(window).scrollTop()),
                        sl = Math.max($(document.body).scrollLeft(), $(window).scrollLeft());
                    window.scrollTo(sl, st);
                    setTimeout('window.scrollTo(' + sl + ',' + st + ');', 10);
                    $.fn.__repositionTransparentDiv();
                };

                //OCULTA LA VENTANA DE CARGA
                $.fn.hide_div_loader = function() {
                    divs_transparentDiv.css('display', 'none');
                    divs_transparentDivImg.css('display', 'none');
                };
                
                //DESCOMENTAR EL CARGANDO
                //$.fn.show_div_loader();

                //FUNCION PARA DIALOGO DE MENSAJES
                $.fn.mensajes = function(dialogo, titulo, mensaje){
                    titulo = (titulo != '') ? titulo : 'Aviso';
                    mensaje = (mensaje != '') ? mensaje : 'Ha ocurrido un problema, intentelo de nuevo';
                    dialogo.dialog('option', 'title', titulo);
                    dialogo.html(mensaje);
                    dialogo.dialog('open');
                };
                
                //FUNCION PARA REEMPLAZAR PUNTOS POR COMAS
                $.fn.addCommas = function(nStr) {
                    nStr += '';
                    x = nStr.split('.');
                    x1 = x[0];
                    x2 = x.length > 1 ? ',' + x[1] : '';
                    var rgx = /(\d+)(\d{3})/;
                    while (rgx.test(x1)) {
                        x1 = x1.replace(rgx, '$1' + '.' + '$2');
                    }
                    var total = x1 + x2;
                    if (total.indexOf(',') == -1)
                        total = total + ",00";
                    return total;
                };

                //OPCIONES POR DEFECTO PARA MOSTRAR MENSAJES DE VALIDACION EN TOOLTIPS
                $.validator.setDefaults({
                    showErrors: function(map, list) {
                        // there's probably a way to simplify this
                        var focussed = document.activeElement;
                        if (focussed && $(focussed).is("input, textarea, select")) {
                            $(this.currentForm).tooltip("close", { currentTarget: focussed }, true)
                        }
                        this.currentElements.removeAttr("title").removeClass("error");
                        $.each(list, function(index, error) {
                            $(error.element).attr("title", error.message).addClass("error");
                        });
                        if (focussed && $(focussed).is("input, textarea, select")) {
                            $(this.currentForm).tooltip("open", { target: focussed });
                        }
                    }
                });
                
                //OPCIONES POR DEFECTO DEL CALENDARIO
                $.datepicker.setDefaults({
                    showButtonPanel: true,
                    currentText: 'Hoy',
                    buttonText: '',
                    firstDay: 1,
                    weekHeader: "Sem",
                    showAnim: "slideDown",
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: "dd-mm-yy",
                    minDate: '<?php echo date('d-m-Y'); ?>',
                    maxDate: '+1m',
                    closeText: "Cerrar",
                    prevText: "Ant",
                    nextText: "Sig",
                    monthNames: ["Enero","Febrero","Maazo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],
                    monthNamesShort: ["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],
                    dayNames: ["Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado"],
                    dayNamesShort: ["Dom","Lun","Mar","Mie","Jue","Vie","Sab"],
                    dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sa"]
                });
                
                $.datepicker._gotoTodayOriginal = $.datepicker._gotoToday;
                $.datepicker._gotoToday = function(id) {
                    $.datepicker._gotoTodayOriginal.apply(this, [id]);
                    $.datepicker._selectDate.apply(this, [id]);
                };
                
                //OPCIONES POR DEFECTO Y VARIABLES GLOBALES DE DIALOGOS
                $.extend($.ui.dialog.prototype.options, {
                    autoOpen: false,
                    modal: true,
                    resizable: false,
                    //closeOnEscape: false,
                    dialogClass: "no-close",
                    draggable: false,
                    close: function(){
                    },
                    open: function(){
                    }
                });
                
                //OPCIONES POR DEFECTO DEL DATATABLE
                $.extend($.fn.dataTable.defaults, {
                    /*"preDrawCallback": function( settings ) {
                        $.fn.show_div_loader();
                    },
                    "initComplete": function(settings, json) {
                        $.fn.hide_div_loader();
                    },
                    "drawCallback": function( settings ) {
                        $.fn.hide_div_loader();
                    },*/
                    "language": {
                        "decimal": ",",
                        "thousands": ".",
                        "lengthMenu": "Mostrar _MENU_ registros por página",
                        "zeroRecords": "No hay registros que coincidan con la b&uacute;squeda",
                        "infoEmpty": "No hay registros",
                        "emptyTable": "No hay registros",
                        "info": "Pagina _PAGE_ de _PAGES_",
                        "infoFiltered": "(filtrado de _MAX_ registros)",
                        "loadingRecords": "Cargando...",
                        "processing": "Procesando...",
                        "search": "Buscar:",
                        "paginate": {
                            "first": "Primero",
                            "last": "Último",
                            "next": "Siguiente",
                            "previous": "Anterior"
                        },
                    },
                    "aoColumnDefs": [{
                        "bSortable": false,
                        "aTargets": [ "no_ordenar" ]
                    }],
                    "createdRow": function( row, data, dataIndex ) {
                        $('a.ver', dataIndex).button({icons: {primary: 'ui-icon-search'}, text: false});
                        $('a.editar', dataIndex).button({icons: {primary: 'ui-icon-pencil'}, text: false});
                        $('a.eliminar', dataIndex).button({icons: {primary: 'ui-icon-trash'}, text: false});
                        $('a.eliminar', dataIndex).button({icons: {primary: 'ui-icon-trash'}, text: false});
                        $('button.pendiente', dataIndex).button({icons: {primary: 'ui-icon-clock'}, text: false});
                        $('button.conectado', dataIndex).button({icons: {primary: 'ui-icon-bullet'}, text: false});
                        $('button.alquilada', dataIndex).button({icons: {primary: 'ui-icon-calendar'}, text: false});
                        $('button.activo', dataIndex).button({icons: {primary: 'ui-icon-circle-check'}, text: false});
                        $('button.mantenimiento', dataIndex).button({icons: {primary: 'ui-icon-wrench'}, text: false});
                        $('button.inactivo', dataIndex).button({icons: {primary: 'ui-icon-circle-close'}, text: false});
                        $('button.desconectado', dataIndex).button({icons: {primary: 'ui-icon-radio-off'}, text: false});
                    }
                });
                
                //DEFINICION PARA MASKEDINPUT
                $.mask.definitions['j'] = '[jgJG]';
                $.mask.definitions['n'] = '[vejgVEJG]';
                $.mask.definitions['t'] = '[AaPp]';

                //DIALOGO DE AVISOS Y MENSAJES
                dialogoAvisos = $("div#dialogoAvisos").dialog({
                    width: 'auto',
                    buttons: [{
                        text: 'Cerrar',
                        icons: {primary: "ui-icon-closethick"},
                        click: function() {
                            $(this).dialog("close");
                        }
                    }]
                });
                
                //DIALOGO PARA CONFIRMAR O CANCELAR
                dialogoConfirmacion = $("div#dialogoConfirmacion").dialog({
                    width: 'auto',
                    buttons: [{
                        text: 'Aceptar',
                        icons: {primary: "ui-icon-check"},
                        click: function() {
                            $(this).dialog("close");
                        }
                    }, {
                        text: 'Cancelar',
                        icons: {primary: "ui-icon-cancel"},
                        click: function() {
                            $(this).dialog("close");
                        }
                    }]
                });
                
                var icons = {
                    header: "ui-icon-circle-arrow-e",
                    activeHeader: "ui-icon-circle-arrow-s"
                };
                $("#menu").accordion({heightStyle: "content", collapsible: true, icons: icons, active: false});
                
                /*$('a.editar').button({icons: {primary: 'ui-icon-pencil'}, text: false});
                $('a.eliminar').button({icons: {primary: 'ui-icon-trash'}, text: false});*/
                $('a.nuevo').button({icons: {primary: 'ui-icon-document'}});
                $('button.guardar').button({icons: {primary: 'ui-icon-disk'}});
                $('a.cancelar').button({icons: {primary: 'ui-icon-cancel'}});
                $('button.agregar').button({icons: {primary: 'ui-icon-plus'}, text: false});
                $('button.quitar').button({icons: {primary: 'ui-icon-minus'}, text: false});
                
                $('.menuHijo').click(function(){
                    var menuHijo = $(this).text(),
                        menuPadre = $(this).parent().parent().parent().prev().text();
                    localStorage.setItem('m_padre', menuPadre);
                    localStorage.setItem('m_hijo', menuHijo);
                });
                
                if(localStorage.getItem('m_padre') != null && localStorage.getItem('m_hijo') != null) {
                    $('#menu').find('h3:contains(' + localStorage['m_padre'] + ')').trigger('click');
                    $('#menu').find('div.ui-accordion-content > ul#lista_accordion > li > a.menuHijo:contains(' + localStorage['m_hijo'] + ')').addClass('over');
                    $('div.crumb_navigation > span.current').html(localStorage['m_padre'] + ' > ' + localStorage['m_hijo']);
                    //<div class="crumb_navigation">Navigation: <span class="current">Home</span></div>
                } else
                    $('div.crumb_navigation > span.current').html();
                
                $('a.nav').click(function(){
                    localStorage.clear();
                });
                
                $('input.fd').datepicker({
                    onSelect: function(selectedDate){
                        $('input.fh').val(selectedDate);
                    },
                    onClose: function(selectedDate){
                        if(selectedDate){
                            var date2 = $(this).datepicker('getDate');
                            $('input.fh').datepicker("option", "minDate", date2);
                        }
                    }
                });

                $('input.fh').datepicker({
                    onSelect: function(selectedDate){
                        $('input.fd').datepicker({
                            maxDate: selectedDate
                        });
                    },
                    onClose: function(selectedDate){
                        if(selectedDate){
                            var date2 = $(this).datepicker('getDate');
                            $('input.fd').datepicker("option", "maxDate", date2);
                        }
                    }
                });

                $('input.cedrif').on({
                    focus: function() {
                        $(this).mask("n?999999999");
                    },
                    blur: function() {
                        $(this).unmask();
                    }
                });

                $('input.telf').on({
                    focus: function() {
                        $(this).mask("9999-9999999");
                    },
                    blur: function() {
                        $(this).unmask();
                    }
                });
                
                $('input.hora').on({
                    focus: function() {
                        $(this).mask("99:00 tM");
                    },
                    blur: function() {
                        $(this).unmask();
                    }
                });
            });
        </script>
    </head>
    <body>
        <div id="div_loader" align="center" class="pageloader"></div>
        <div align="center" id="div_loader_img" style="display:none;z-index:9999;position:absolute;top:35%;left:38%;">
            <?php echo $this->Html->image('sisvenla/ajax-loader.gif', array('style' => 'padding-top: 40px;')); ?>
            <br />
            <?php echo 'CARGANDO POR FAVOR ESPERE' ?>
        </div>
        <div id="main_container">
            <div id="header">
                <div id="logo"><?php echo $this->Html->image('sisvenla/lavadora_sinfondo.png', array('style' => 'width: 150px; height: 100px;')); ?></div>
                <div id="escudo"><?php echo $this->Html->image('sisvenla/escudo_aragua.png'); ?></div>
                <!--div class="oferte_content">
                    <div class="top_divider"><img src="img/header_divider.png" alt="" title="" width="1" height="164" /></div>
                    <div class="oferta">
                        <div class="oferta_content">
                            <img src="img/laptop.png" width="94" height="92" border="0" class="oferta_img" />
                            <div class="oferta_details">
                                <div class="oferta_title">Samsung GX 2004 LM</div>
                                <div class="oferta_text">
                                    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
                                </div>
                                <a href="details.html" class="details">details</a>
                            </div>
                        </div>
                        <div class="oferta_pagination">
                            <span class="current">1</span>
                            <a href="#?page=2">2</a>
                            <a href="#?page=3">3</a>
                            <a href="#?page=3">4</a>
                            <a href="#?page=3">5</a>  
                        </div>        
                    </div>
                    <div class="top_divider"><img src="img/header_divider.png" alt="" title="" width="1" height="164" /></div>
                </div-->
            </div>
            <div id="main_content">
                <div id="menu_tab">
                    <div class="left_menu_corner"></div>
                    <ul class="menu">
                        <li class="nav">Usuario: <span class="nav_det"><?php echo ucfirst($this->Session->read('usuario')); ?></span></li>
                        <li class="divider"></li>
                        <li class="nav">Perfil: <span class="nav_det"><?php echo $this->Session->read('perfil_nombre'); ?></span></li>
                        <li class="divider"></li>
                        <li class="nav">&Uacute;ltimo Acceso: <span class="nav_det"><?php echo $this->Util->fecha_hora($this->Session->read('ultimo_acceso')); ?></span></li>
                        <li class="divider"></li>
                        <li class="nav">Fecha Sistema: <span class="nav_det"><?php echo date('d-m-Y h:i a'); ?></span></li>
                        <li class="divider"></li>
                        <li><?php echo $this->Html->link('Salir', '/Usuarios/cerrar_session', array('class' => 'nav')); ?></li>
                        <li class="divider"></li>
                    </ul>
                    <div class="right_menu_corner"></div>
                </div>
                <div class="crumb_navigation">Navegaci&oacute;n: <span class="current">Inicio</span></div>
                <div id="menu" class="left_content">
                    <h3>Maestros</h3>
                    <div>
                        <ul id="lista_accordion">
                            <?php if($perfilId == 1){ ?>
                            <li><?php echo $this->Html->link('Clientes', '/Clients/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Categorías', '/Categorias/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Unidades de Medida', '/UnidadMedidas/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Artículos', '/Articulos/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Tipos', '/Tipos/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Marcas', '/Marcas/index', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Modelos', '/Modelos/index', array('class' => 'menuHijo')); ?></li>
                            <?php } ?>
                            <li><?php echo $this->Html->link('Lavadoras', '/Lavadoras/index', array('class' => 'menuHijo')); ?></li>
                        </ul>
                    </div>
                    <h3>Solicitudes</h3>
                    <div>
                        <ul id="lista_accordion">
                            <li><?php echo $this->Html->link('Alquiler', '/Solicituds/index/1', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Reparación', '/Solicituds/index/2', array('class' => 'menuHijo')); ?></li>
                        </ul>
                    </div>
                    <?php if($perfilId == 1){ ?>
                        <h3>Procesos</h3>
                        <div>
                            <ul id="lista_accordion">
                                <li><?php echo $this->Html->link('Inventario', '/Articulos/inventario', array('class' => 'menuHijo')); ?></li>
                                <li><?php echo $this->Html->link('Ventas', '/Ventas/index', array('class' => 'menuHijo')); ?></li>
                            </ul>
                        </div>
                    <?php } ?>
                    <h3>Reportes</h3>
                    <div>
                        <ul id="lista_accordion">
                            <li><?php echo $this->Html->link('Clientes', '/Clients/reporte', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Artículos', '/Articulos/reporte', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Inventario', '/Articulos/inventario_reporte', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Ventas', '/Ventas/reporte', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Alquiler', '/Alquilers/reporte', array('class' => 'menuHijo')); ?></li>
                            <li><?php echo $this->Html->link('Reparaciones', '/Reparacions/reporte', array('class' => 'menuHijo')); ?></li>
                            <!--p>Auditor&iacute;a</p-->
                        </ul>
                    </div>
                    <h3>Configuraci&oacute;n</h3>
                    <div>
                        <ul id="lista_accordion">
                            <?php if($perfilId == 1){ ?>
                                <li><?php echo $this->Html->link('Usuarios', '/Usuarios/index', array('class' => 'menuHijo')); ?></li>
                                <li><?php echo $this->Html->link('Cambio de Clave', '/Usuarios/clave', array('class' => 'menuHijo')); ?></li>
                                <li><?php echo $this->Html->link('Mantenimiento', '/Mantenimientos/index', array('class' => 'menuHijo')); ?></li>
                            <?php } elseif($perfilId == 2){ ?>
                                <li><?php echo $this->Html->link('Cambio de Clave', '/Usuarios/clave', array('class' => 'menuHijo')); ?></li>
                            <?php } ?>
                        </ul>
                    </div>
                </div>
                <div id="center_content" class="center_content">
                    <?php echo $this->Session->flash(); ?>
                    <div class="panel panel-default">
                        <?php echo $this->fetch('content'); ?>
                    </div>
                </div>
            </div>
            <div class="footer">
                <!--div class="left_footer"><img src="img/footer_logo.png" alt="" title="" width="170" height="49"/></div-->
                <div class="center_footer">Sistema de Venta de Lavadoras - SISVENLA</br>&copy; 2014 Todos los Derechos Reservados.</div>
                <!--div class="right_footer">
                    <a href="index.html">home</a>
                    <a href="details.html">about</a>
                    <a href="details.html">sitemap</a>
                    <a href="details.html">rss</a>
                    <a href="contact.html">contact us</a>
                </div-->
            </div>
        </div>
        <div id="dialogoAvisos" title="Aviso" class="centro"></div>
        <div id="dialogoConfirmacion" title="Aviso"></div>
    </body>
</html>